<template>
<h1>用户登录</h1>
  <div>
    <form @submit.prevent="registerUser">
      <label for="username">用户名：</label>
      <input type="text" id="username" v-model="userData.username" required />

      <label for="password">密码：</label>
      <input type="password" id="password" v-model="userData.password" required />

      <ElButton @click="registerUser" type="submit">登录</ElButton>
    </form>
  </div>

</template>

<script>
import axios from "axios";
import { ElButton } from 'element-plus'
export default {
  components:{
    ElButton
  },
  name: "UserLogin",
  data() {
    return {
      userData: {
        username: '',
        password: '',
      },
    };
  },
  methods: {
    registerUser() {
      // 发送注册请求
      axios.post('http://localhost:8088/user/login', this.userData)
          .then(response => {
            // 注册成功处理
            console.log('注册成功', response.data);
          })
          .catch(error => {
            // 注册失败处理
            console.error('注册失败', error);
          });
    },
  },
}
</script>

<style scoped>

</style>